package com.ybkj.o2o.zhuanxian.common.amqp;

import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfiguration {

  public static final String EXCHANGE_NAME = "";

  @Autowired
  private ConnectionFactory connectionFactory;

  @Bean
  public FanoutExchange shopExchange() {
    return new FanoutExchange(EXCHANGE_NAME, true, false);
  }

  /**
   * .
   */
  @Bean
  public RabbitTemplate rabbitTemplate() {
    RabbitTemplate template = new RabbitTemplate(connectionFactory);
    template.setExchange(EXCHANGE_NAME);
    template.setMessageConverter(new Jackson2JsonMessageConverter());
    return template;
  }

}
